package com.ruoyi.web.controller.ufox;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ufox.domain.SysHolidaySetting;
import com.ruoyi.ufox.service.ISysHolidaySettingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 假日模板Controller
 * 
 * @author ruoyi
 * @date 2022-08-31
 */
@RestController
@RequestMapping("/ufox/setting")
public class SysHolidaySettingController extends BaseController
{
    @Autowired
    private ISysHolidaySettingService sysHolidaySettingService;

    /**
     * 查询假日模板列表
     */
    @PreAuthorize("@ss.hasPermi('ufox:setting:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysHolidaySetting sysHolidaySetting)
    {
        startPage();
        List<SysHolidaySetting> list = sysHolidaySettingService.selectSysHolidaySettingList(sysHolidaySetting);
        return getDataTable(list);
    }

    /**
     * 导出假日模板列表
     */
    @PreAuthorize("@ss.hasPermi('ufox:setting:export')")
    @Log(title = "假日模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysHolidaySetting sysHolidaySetting)
    {
        List<SysHolidaySetting> list = sysHolidaySettingService.selectSysHolidaySettingList(sysHolidaySetting);
        ExcelUtil<SysHolidaySetting> util = new ExcelUtil<SysHolidaySetting>(SysHolidaySetting.class);
        util.exportExcel(response, list, "假日模板数据");
    }

    /**
     * 获取假日模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('ufox:setting:query')")
    @GetMapping(value = "/{settingId}")
    public AjaxResult getInfo(@PathVariable("settingId") Long settingId)
    {
        return AjaxResult.success(sysHolidaySettingService.selectSysHolidaySettingBySettingId(settingId));
    }

    /**
     * 新增假日模板
     */
    @PreAuthorize("@ss.hasPermi('ufox:setting:add')")
    @Log(title = "假日模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysHolidaySetting sysHolidaySetting)
    {
        return toAjax(sysHolidaySettingService.insertSysHolidaySetting(sysHolidaySetting));
    }

    /**
     * 修改假日模板
     */
    @PreAuthorize("@ss.hasPermi('ufox:setting:edit')")
    @Log(title = "假日模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysHolidaySetting sysHolidaySetting)
    {
        return toAjax(sysHolidaySettingService.updateSysHolidaySetting(sysHolidaySetting));
    }

    /**
     * 删除假日模板
     */
    @PreAuthorize("@ss.hasPermi('ufox:setting:remove')")
    @Log(title = "假日模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{settingIds}")
    public AjaxResult remove(@PathVariable Long[] settingIds)
    {
        return toAjax(sysHolidaySettingService.deleteSysHolidaySettingBySettingIds(settingIds));
    }
}
